package com.eastcom.providor.util;

import java.util.Date;

import com.eastcom.canicula.stope.utils.DateUtil;

public class TimeSwap {

	public static final int ORACLE_TYPE=1;
	public static final int SYBASE_TYPE=2;
	
	public static String swap(Date date,int type)
	{
		String standExpression=DateUtil.DateToString(date);
		String ret=null;
		switch(type)
		{
		case ORACLE_TYPE:
			ret="to_date('"+standExpression+"','yyyy-MM-dd hh24:mi:ss')";
			break;
		case SYBASE_TYPE:
			ret="'"+standExpression+"'";
			break;
		}
		return ret;
	}
	
	public static String swap(String timeField,String type){
		String ret=null;
		if("oracle".equalsIgnoreCase(type)){
			ret="to_char("+timeField+",'yyyy-MM-dd hh24:mi:ss')";
		}else{
			ret=timeField;
		}
		return ret;
	}
	
	public static void main(String[] args)
	{
		Date date=new Date();
		System.out.println(TimeSwap.swap(date, ORACLE_TYPE));
		String field=TimeSwap.swap("start_time", "sybase");
		System.out.println(field);
	}
}
